﻿#include "MainWindow.h"
#include "./ui_MainWindow.h"

#include <QDebug>
#include <QTextEdit>
#include <QLabel>
#include <QPalette>
#include <QHBoxLayout>
#include <QGridLayout>

#include "LogBox.h"


#define APP_NAME "Qt Widget Base"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowTitle(APP_NAME);
    setWindowIcon(QIcon("widget.ico"));

    container = new QWidget(this);
    QVBoxLayout *vBox = new QVBoxLayout;
    QGridLayout *gBox = new QGridLayout;
    title = new QLabel(APP_NAME);
    editCst = new LogBox;
    editPdc = new LogBox;

    vBox->addWidget(title);
    vBox->addLayout(gBox);
    gBox->addWidget(new QLabel("Producer"), 0, 0, Qt::AlignCenter);
    gBox->addWidget(editPdc, 1, 0);
    gBox->addWidget(new QLabel("Customer"), 0, 1, Qt::AlignCenter);
    gBox->addWidget(editCst, 1, 1);

    container->setLayout(vBox);
    setCentralWidget(container);

    gBox->setContentsMargins(10, 10, 10, 10);
    gBox->setRowStretch(0, 5);
    gBox->setRowStretch(1, 95);
    title->setFont(QFont("Microsoft YaHei", 12));
    title->setAlignment(Qt::AlignCenter);

    qDebug() << "App Running in" << QApplication::platformName();
}

MainWindow::~MainWindow()
{
    delete ui;
}
